Skip to content

Conversation

chrisbbe
Copy link

We have issues where log events with LogLevel.None are written to Seq, which it should not according to MS LogLevel documentation

@nblumhardt
Copy link
Member

Thanks for the PR!

This seems reasonable on the surface, but probably indicates a bug further up the stack in your logging pipeline: loggers shouldn't construct events or invoke providers with the None level.

There's an ILogger.Error() method, for example, but no ILogger.None() method. How are these events being created in the first place?

@chrisbbe
Copy link
Author

That's the reason for the IsEnabled(LogLevel) method: to check which logger is enabled for the given level, before the event enters the provider.

It's correct that you don’t have a specific ILogger.None(), but there is the more general Log(ILogger, LogLevel, ...) commonly used when the level is dynamically determined during runtime.

@nblumhardt
Copy link
Member

That's the reason for the IsEnabled(LogLevel) method: to check which logger is enabled for the given level, before the event enters the provider.

I don't think that's necessarily the case. In the documentation you linked, note that the description for None begins with:

Not used for writing log messages.

This is different from "Used when a log message shouln't be written". The None value is a filter, it's not a valid level on events, and even code that calls ILogger.Log() dynamically should never call this method with the None value.

There's still possibly a bug somewhere, but it's likely to be in whatever is calling the IsEnabled() function. Happy to help track it down if you can send any further details.

Cheers!

@chrisbbe
Copy link
Author

chrisbbe commented Oct 8, 2025

For our case, it's Wolverine that's spam with log events with level None, as you can see, the log level is not determined at the point of time of logging.

Both the built-in console logger and Sentry have a check against None level in IsEnabled(), as seen here.

The only bug I can see is that the Seq provider does not discard None events. Are we on the same page?

@nblumhardt
Copy link
Member

Thanks for digging in deeper. Ugh, yes, I can see how this comes together :) ... awful, but I think you're right 👍

@nblumhardt nblumhardt merged commit cdd393b into datalust:dev Oct 8, 2025
1 check passed
@nblumhardt nblumhardt mentioned this pull request Oct 9, 2025
@nblumhardt
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants